from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse

from .models import Question

def index(request):
    # 显示最新的5条问题
    questions = Question.objects.all().order_by('-pub_date')[:5]
    return render(request, "polls/index.html", {'questions': questions})


def detail(request, pk):
    q = get_object_or_404(Question, pk=pk)
    return render(request, "polls/detail.html", {'q': q})


def results(request):
    ...


def vote(request):
    ...
